package com.sdkj.Entity.service;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Type;

import com.sdkj.Entity.BaseEntity;
import com.sdkj.Entity.sys.Images;

@Entity
@Table(name="news")
public class News extends BaseEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private String title;
	private String subtitle;
	private Date newsTime;//新闻时间
	private String sumary;
	private String content;
	private String type;//1 公司动态，2 ， 行业动态
	private Images img;
	
	private String imgUrl;
	
	@Transient
	public String getImgUrl() {
		return img==null?"/images/lunbo/01.jpg":img.getImgUrl();
	}
	public void setImgUrl(String imgUrl) {
		this.imgUrl = imgUrl;
	} 
	public void setTitle(String title) {
		this.title = title;
	}
	public void setSubtitle(String subtitle) {
		this.subtitle = subtitle;
	}
	public void setNewsTime(Date newsTime) {
		this.newsTime = newsTime;
	}
	public void setSumary(String sumary) {
		this.sumary = sumary;
	}
	public void setContent(String content) {
		this.content = content;
	}
	@Column(length=200)
	public String getTitle() {
		return title;
	}
	@Column(length=200)
	public String getSubtitle() {
		return subtitle;
	}
	@Column(length=20)
	public Date getNewsTime() {
		return newsTime;
	}
	@Column(length=200)
	public String getSumary() {
		return sumary;
	}
	@Type(type="text") 
	@Column
	public String getContent() {
		return content;
	}
	@Column(length=20)
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "img")
	public Images getImg() {
		return img;
	}
	public void setImg(Images img) {
		this.img = img;
	}
	public News() {
		super();
	}
	public News(String uuid, Date createTime) {
		super(uuid, createTime);
	}
	public News(String title, String subtitle, Date newsTime, String sumary,
			String content, Images imgs) {
		super();
		this.title = title;
		this.subtitle = subtitle;
		this.newsTime = newsTime;
		this.sumary = sumary;
		this.content = content;
		this.img = imgs;
	}
	@Override
	public String toString() {
		return "News [title=" + title + ", subtitle=" + subtitle
				+ ", newsTime=" + newsTime + ", sumary=" + sumary
				+ ", content=" + content + ", imgs=" + img + "]";
	}

}
